package com.project.mapper;

import com.project.pojo.Library;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface LibraryMapper {
    /**
     *
     * @return
     */
    @Select("select * from book")
    @ResultMap("libraryResultMap")
    List<Library> selectAll();

    /**
     * 通过id查询
     * @param id
     * @return
     */
   @Select("select * from book where Book_id=#{id}")
   @ResultMap("libraryResultMap")
    Library selectById(int id);

    /**
     *
     *#{bookName),#{bookAuthor},#{bookStutas},#{bookPrice}
     */
    @Insert("insert into book values (#{bookId},#{bookName},#{bookAuthor},#{bookStutas},#{bookPrice})")

    @ResultMap("libraryResultMap")
    void add(Library library);

    /**
     *
     *
     * @param library
     */
    @Delete("delete from book where Book_id =#{bookId} ")
    @ResultMap("libraryResultMap")
    void deleteByid(Library library);


    @Update("update book set Book_id = #{bookId},Book_name=#{bookName},Book_author = #{bookAuthor},Book_stutas = #{bookStutas},Book_price = #{bookPrice} where Book_id = #{bookId}")
    @ResultMap("libraryResultMap")
    void update(Library library);


}
